<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <p id="p">hello world</p>
    <!-- 
        onmouseover 鼠标悬停在元素上时触发
        onmouseout   鼠标移开时触发
     -->
    <script>
        var p = document.getElementById("p")
        p.onmouseover = function(){
            p.style.background = "red"
        }
        p.onmouseout = function(){
            p.style.background = "green"
        }
    </script>
</body>
</html>